package com.jiutong.meipenggang.http.present;

import android.content.Context;

import com.jiutong.meipenggang.entity.InvestDetailBean;
import com.jiutong.meipenggang.http.model.interfaces.InvestDetailBiz;
import com.jiutong.meipenggang.http.model.requests.MeiLiCaiFragmentRequest;
import com.jiutong.meipenggang.http.subscribers.ProgressSubscriber;
import com.jiutong.meipenggang.http.subscribers.SubscriberOnNextListener;

import java.util.HashMap;

/**
 * @author Veken
 * @date on 2017/12/20 9:48
 * @describe  获取单个标的详细信息
 */

public class InvestDetailPresent {

    private Context mContext;
    private InvestDetailBiz investDetailBiz;
    private MeiLiCaiFragmentRequest meiLiCaiFragmentRequest;

    public InvestDetailPresent(Context mContext, InvestDetailBiz investDetailBiz) {
        this.mContext = mContext;
        this.investDetailBiz = investDetailBiz;
        meiLiCaiFragmentRequest = new MeiLiCaiFragmentRequest();
    }

    /**
     * 获取美理财单个标的详细信息
     */
    public void getInvestDetailInfo(){
        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<InvestDetailBean>() {
            @Override
            public void onNext(InvestDetailBean object) {
                investDetailBiz.onSuccess(object);
            }
            @Override
            public void onError(Throwable e) {
                investDetailBiz.onError(e);
            }
        };
        HashMap<String,Object> fieldMap = new HashMap<>();
        fieldMap.put("OPT",investDetailBiz.getOpt());
        fieldMap.put("bidId",investDetailBiz.getBidId());
        meiLiCaiFragmentRequest.getInvestDetailInfo(new ProgressSubscriber(onNextListener,mContext),fieldMap);
    }
}
